// 属性管理接口
import request from '@/utils/request'
import type { CategoryResponseData, AttrResponseData, Attr } from './type'
enum API {
    // 一级分类地址
    C1_URL = '/admin/product/getCategory1',
    C2_URL = '/admin/product/getCategory2/',
    C3_URL = '/admin/product/getCategory3/',
    // 分类下已有的属性与属性值
    ATTR_URL = '/admin/product/attrInfoList/',
    // 添加或者修改已有属性接口
    ADDORUPDATEATTR = '/admin/product/saveAttrInfo',
    // 删除某一个已有属性
    DELETEATTR = '/admin/product/deleteAttr/'
}

export const C1API = () => request.get<any, CategoryResponseData>(API.C1_URL)

export const C2API = (category1Id: number) => request.get<any, CategoryResponseData>(API.C2_URL + category1Id)

export const C3API = (category2Id: number) => request.get<any, CategoryResponseData>(API.C3_URL + category2Id)
// 分类下已有的属性与属性值
export const AttrAPI = (category1Id: number | string, category2Id: number | string, category3Id: number | string) => request.get<any, AttrResponseData >(API.ATTR_URL + `${category1Id}/${category2Id}/${category3Id}`)

// 添加或者修改已有属性接口
export const AddOrUpdateAttrAPI = (data: Attr) => request.post<any, any>(API.ADDORUPDATEATTR, data)

// // 删除某一个已有属性
export const RemoveAttrAPI = (attrId: number) => request.delete<any, any>(API.DELETEATTR + attrId)